// url: https://leetcode.cn/problems/remove-duplicates-from-sorted-array/?envType=study-plan-v2&envId=top-interview-150
package interview_classic.array_or_str;

public class Solution26 {
    public int removeDuplicates(int[] nums) {
        if (nums.length == 1 || nums.length == 0) return nums.length;
        int validLen = 1, curNum = nums[0];
        for (int i = 1; i < nums.length; i++) {
            if (curNum != nums[i]) {
                curNum = nums[i];
                nums[validLen++] = curNum;
            }
        }
        return validLen;
    }

}
